package org.linlinjava.litemall.core.vo;

import org.apache.commons.lang3.StringUtils;
import org.linlinjava.litemall.core.util.bcrypt.BCryptPasswordEncoder;
import org.linlinjava.litemall.db.domain.VendorEmployee;

public class VendorRegVo {
    private String username;
    private String password;
    private String phone;
    private String captcha;

    public VendorEmployee toVendorEmployee() {
        VendorEmployee emp = new VendorEmployee();

        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        String encodedPassword = encoder.encode(password);
        emp.setPassword(encodedPassword);
        emp.setUsername(username);
        emp.setPhone(phone);
        return emp;
    }

    public boolean isValid() {
        if (StringUtils.isAnyBlank(username, password, phone, captcha)) {
            return false;
        }
        return true;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCaptcha() {
        return captcha;
    }

    public void setCaptcha(String captcha) {
        this.captcha = captcha;
    }
}
